<template>
  <j-modal
    :visible.sync='visible'
    :width='1200'
    :title='title'
  >
    <!-- table区域-begin -->
    <template>
      <div>
        <a-table
          ref='table'
          size='middle'
          :scroll='{x:true}'
          bordered
          rowKey='id'
          :columns='columns'
          :dataSource='dataSourceModal'
          :pagination='ipagination'
          :loading='loading'
          class='j-table-force-nowrap'
          @change='handleTableChange'>

          <template slot='htmlSlot' slot-scope='text'>
            <div v-html='text'></div>
          </template>
          <template slot='imgSlot' slot-scope='text'>
            <span v-if='!text' style='font-size: 12px;font-style: italic;'>无图片</span>
            <img v-else :src='getImgView(text)' height='25px' alt=''
                 style='max-width:80px;font-size: 12px;font-style: italic;' />
          </template>
          <template slot='fileSlot' slot-scope='text'>
            <span v-if='!text' style='font-size: 12px;font-style: italic;'>无文件</span>
            <a-button
              v-else
              :ghost='true'
              type='primary'
              icon='download'
              size='small'
              @click='downloadFile(text)'>
              下载
            </a-button>
          </template>

          <span slot='action' slot-scope='text, record'>
           <a @click='handleSelect(record)'>选择</a>
        </span>

        </a-table>
      </div>
    </template>
    <template slot='footer'>
      <a-button @click='closeMessage'>关闭</a-button>
    </template>
  </j-modal>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'

export default {
  name: 'TeaTeacherListModal',
  mixins: [JeecgListMixin, mixinDevice],
  components: {},
  props: {
    dataSourceModal: {
      type: Array,
      default: []
    },
    title: {
      type: String,
      default: '选择教师'
    }
  },
  data() {
    return {
      description: 'tea_teacher管理页面',
      // 表头
      columns: [
        {
          title: '所属部门',
          align: 'center',
          dataIndex: 'sysOrgCode_dictText'
        },
        {
          title: '教职工号',
          align: 'center',
          dataIndex: 'teacherFacultyCode'
        },
        {
          title: '姓名',
          align: 'center',
          dataIndex: 'teacherName'
        },
        {
          title: '登录账号',
          align: 'center',
          dataIndex: 'userId_dictText'
        },

        {
          title: '电话号码',
          align: 'center',
          dataIndex: 'teacherTel'
        },
        {
          title: '昵称(简称)',
          align: 'center',
          dataIndex: 'teacherNickname'
        },
        {
          title: '拼音',
          align: 'center',
          dataIndex: 'teachernamePinyin'
        },
        {
          title: '显示顺序',
          align: 'center',
          dataIndex: 'teacherOrder'
        },
        {
          title: '出生日期',
          align: 'center',
          dataIndex: 'teacherBirth',
          customRender: function(text) {
            return !text ? '' : (text.length > 10 ? text.substr(0, 10) : text)
          }
        },
        {
          title: '性别',
          align: 'center',
          dataIndex: 'teacherGender_dictText'
        },
        {
          title: '身份证号码',
          align: 'center',
          dataIndex: 'teacherIdNumber'
        },
        {
          title: '邮箱地址',
          align: 'center',
          dataIndex: 'teacherEmail'
        },
        {
          title: '微信号',
          align: 'center',
          dataIndex: 'teacherWechatId'
        },
        {
          title: 'QQ',
          align: 'center',
          dataIndex: 'teacherQqId'
        },
        {
          title: '户籍',
          align: 'center',
          dataIndex: 'teacherRegistered'
        },
        {
          title: '家庭住址',
          align: 'center',
          dataIndex: 'teacherAddress'
        },
        {
          title: '描述',
          align: 'center',
          dataIndex: 'teacherIntroduce'
        },
        {
          title: '职称',
          align: 'center',
          dataIndex: 'teacherTitle'
        },
        {
          title: '毕业院校',
          align: 'center',
          dataIndex: 'teacherUniversity'
        },
        {
          title: '最高学历',
          align: 'center',
          dataIndex: 'teacherDegree'
        },
        {
          title: '教师资格证编号',
          align: 'center',
          dataIndex: 'teacherCertificateCode'
        },
        {
          title: '银行卡号',
          align: 'center',
          dataIndex: 'teacherBankId'
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'teacherStatus_dictText'
        },
        {
          title: '创建时间',
          align: 'center',
          dataIndex: 'createTime'
        },
        {
          title: '民族',
          align: 'center',
          dataIndex: 'teacherNation_dictText'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      visible: false
    }
  },
  created() {

  },
  computed: {

  },
  methods: {
    loadData() {

    },
    openModal() {
      if (this.visible === false) {
        this.visible = true
      }
    },
    closeMessage() {
      if (this.visible === true) {
        this.visible = false
      }
      this.$bus.$emit('closeTeaTeacherListModal', {})
    },
    handleSelect(val) {
      if (this.visible === true) {
        this.visible = false
      }
      this.$bus.$emit('closeTeaTeacherListModal', val)
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>